import http from "@/http";
export const getProductListApi = (params: any): RES<any> =>
  http.get("/product/list", { params });

//商品分类
export const getProductCategoryListAPI = (
  params: IProductCategoryListParams
): RES<IGetProductCategoryList> =>
  http.get(
    `/productCategory/list/${params.parentId}?pageNum=${params.pageNum}&pageSize=${params.pageSize}`
  );
// 删除商品分类
export const deleteAttrApi = (id: number): RES<number> => http.post(`/productCategory/delete/${id}`)
// 修改商品分类的导航栏状态
export const updateNavStatusApi = (ids: number[], navStatus: number): RES<number> => http.post(`/productCategory/update/navStatus?ids=${ids.join(",")}&navStatus=${navStatus}`)
// 修改商品分类的显示状态
export const updateShowStatusApi = (ids: number[], showStatus: number): RES<number> => http.post(`/productCategory/update/showStatus?ids=${ids.join(",")}&showStatus=${showStatus}`)
// 所有一级分类及子分类的数据
export const withChildrenListApi = (): RES<IwithChildren[]> => http.get('/productCategory/list/withChildren')

// 商品属性分类及其下属性的数据
export const withAttrListApi = (): RES<IwithAttr[]> => http.get('/productAttribute/category/list/withAttr')

// 提交添加商品分类
export const createAttrListApi = (params: IcreateAttrList): RES<number> => http.post('/productCategory/create', params)
// 编辑商品分类获取对应id数据
export const productCategoryAttrIdApi = (id: any): RES<IEditProductClass> => http.get(`/productCategory/${id}`)

// 修改商品分类
export const modifyAttrListApi = (id: number, productCategoryParam: IcreateAttrList): RES<number> => http.post(`/productCategory/update/${id}`, productCategoryParam)
// 修改商品分类是否显示状态
export const productCategoryShowStatusApi = (id: number, showStatus: number): RES<any> =>
http.post(`/productCategory/update/showStatus?showStatus=${showStatus}&ids=${id}`);
// 修改商品分类导航栏显示状态
export const productCategoryNavStatusApi = (id: number, navStatus: number): RES<any> =>
http.post(`/productCategory/update/navStatus?navStatus=${navStatus}&ids=${id}`);

//品牌管理
export const getBrandListAPI = (params: IBrandListParams): RES<IGetBrandList> =>
  http.get(
    `/brand/list/?keyword=${params.keyword}&pageNum=${params.pageNum}&pageSize=${params.pageSize}`
  );
// 添加品牌
export const brandCreateApi = (params: BrandCreateModel): RES<BrandCreateModel> =>
  http.post("/brand/create", params);

// 编辑品牌数据
export const getUpdateBrandApi = (id: number): RES<BrandCreateModel> =>
  http.get(`/brand/${id}`);
// 编辑品牌
export const UpdateBrandApi = (params: IBrandModel): RES<number> =>
  http.post(`/brand/update/${params.id}`, params);
// 删除品牌
export const DeleteBrandApi = (ids: number): RES<DeleteModel> =>
  http.get(`/brand/delete/${ids}`);
  // 修改品牌制造商状态
export const factoryStatusApi = (id: number, factoryStatus: number): RES<any> =>
http.post(`/brand/update/factoryStatus?factoryStatus=${factoryStatus}&ids=${id}`);  
// 修改品牌是否显示状态
export const showStatusApi = (id: number, showStatus: number): RES<any> =>
http.post(`/brand/update/showStatus?showStatus=${showStatus}&ids=${id}`);
  // 批量修改品牌是否显示状态
export const getShowStatusApiApi = (id: number[],showStatus: number): RES<number> => http.post(`/brand/update/showStatus?showStatus=${showStatus}&ids=${id.join(',')}`)


// 获取属性管理页数据
export const addProductAttrApi = (params: IListParams): RES<IProductAttr> => http.get(`/productAttribute/category/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}`)

// 添加商品属性
export const addAttributeApi = (name: string): RES<number> => http.post(`/productAttribute/category/create?name=${name}`)

// 修改商品属性
export const editAttributeApi = (id: number, name: string): RES<number> => http.post(`/productAttribute/category/update/${id}?name=${name}`)

// 删除指定商品属性
export const delAttributeApi = (id: number): RES<number> => http.get(`/productAttribute/category/delete/${id}`)
// 属性列表
export const productAttributeListApi = (params: ProductAttributeParams): RES<IProductAttribute> => http.get(`/productAttribute/list/${params.cid}?pageNum=${params.pageNum}&pageSize=${params.pageSize}&type=${params.type}`)
// 添加商品属性信息
export const productAttributeCreateApi = (params: productAttributeCreate): RES<number> =>
  http.post("/productAttribute/create", params);
  // 查询单个商品属性
export const productAttributeAttrIdApi = (id: number): RES<IProductAttributeList> => http.get(`/productAttribute/${id}`)
// 修改商品属性信息
export const editProductAttributeApi = (id: number,params: productAttributeCreate): RES<number> => http.post(`/productAttribute/update/${id}`,params)
// 删除指定商品属性信息
export const delProductAttributeApi = (ids: number): RES<number> => http.post(`/productAttribute/delete?ids=${ids}`)
  // 批量删除商品属性信息
  export const getProductAttributeDeleteApi = (id: number[]): RES<number> => http.post(`/productAttribute/delete?ids=${id.join(',')}`)

// 所有一级分类及子分类的数据
export const selectProductTypeListApi = (): RES<any> => http.get('/productCategory/list/withChildren')
//查询所有商品属性列表
export const selectProductPropertyListApi = (): RES<any> => http.get('/productAttribute/category/list/withAttr')

//根据id查询单个商品属性
export const selectProductPropertyByIdApi = (id:any): RES<any> => http.get(`/productAttribute/${id}`)

//根据id查询商品类型的属性和列表参数
export const selectProductListPropertyByIdApi = (params:any): RES<any> =>http.get(`/productAttribute/list/${params.cid}`,{params})
// 获取商品专题
// export const getProductSubjectListApi = (): RES<any> => http.get("/mall-admin/subject/listAll")
export const getProductSubjectListApi = ():RES<any> => http.get("http://xue.cnkdl.cn:9082/mall-admin/subject/listAll")

// 获取商品优选
// export const getProductGoodSelectListApi = (): RES<any> => http.get("/mall-admin/prefrenceArea/listAll")
export const getProductGoodSelectListApi = ():RES<any> => http.get("http://xue.cnkdl.cn:9082/mall-admin/prefrenceArea/listAll")

// 获取商品品牌列表

export const getProductLogoListApi = ():RES<any> => http.get("/brand/listAll")
// 点击修改上架状态
export const publishStatusApi = (ids: number[], publishStatus: number): RES<number> => http.post(`/product/update/publishStatus?ids=${ids.join(",")}&publishStatus=${publishStatus}`)

// 点击修改新品状态
export const newStatusApi = (ids: number[], newStatus: number): RES<number> => http.post(`/product/update/newStatus?ids=${ids.join(",")}&newStatus=${newStatus}`)

// 点击修改推荐状态
export const recommendStatusApi = (ids: number[], recommendStatus: number): RES<number> => http.post(`/product/update/recommendStatus?ids=${ids.join(",")}&recommendStatus=${recommendStatus}`)

// 点击删除
export const delStatusApi = (ids: number[]): RES<number> => http.post(`/product/update/deleteStatus?ids=${ids.join(",")}&deleteStatus=1`)


// 获取货品信息
export const skuApi = (pid: number, keyword: string): RES<SkuModel[]> => http.get(`/sku/${pid}?keyword=${keyword}`)


export const updateSkuAPI = (pid:number,skuStockList:SkuModel[]): RES<number> =>
    http.post(`/sku/update/${pid}`, skuStockList);
// 添加商品属性信息
export const productCreateApi = (params: productCreate): RES<number> =>
http.post("/product/create", params);